<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
	<meta content="telephone=no" name="format-detection"/>
	<title>收货信息</title>
	<link href="<%=path %>/css/stlye.css" rel="stylesheet" type="text/css" />
	<link href="<%=path %>/css/address.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=path%>/js/jquery-1.11.0.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/plugins/layer/layer.js"></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/city_json.js"></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/pro_json.js" ></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/region_json.js"></script>
	<script type="text/javascript">
		$(function () {
			var el = document.createElement("STYLE");
			var docEl = document.documentElement;
			var portrait = ((Math.min(docEl.clientWidth, docEl.clientHeight) / 320) * 10);
			var landscape = ((Math.max(docEl.clientWidth, docEl.clientHeight) / 568) * 17.75);
			el.innerHTML = "@media screen and (orientation:portrait) { html { font-size: " + portrait + "px!important; } }\n@media screen and (orientation:landscape) { html { font-size: " + landscape + "px!important; } }";
			docEl.firstElementChild.appendChild(el);
			
			
			var proValue = "${deliveryAddressVO.deliveryProvince}";

			var cityValue = "${deliveryAddressVO.deliveryCity}";

			var regionValue = "${deliveryAddressVO.deliveryRegion}";

			initProvince();

			if (proValue != null && proValue != '') {
				provinceClick(proValue);
				if (cityValue != null && cityValue != '') {
					cityClick(cityValue);
					if (regionValue != null && regionValue != '') {
						regionClick(regionValue);
					}
				}
			}
		});
	</script>
</head>
<body>

<div class="check-page" style="display: block;" id="address_edit_div">
	<form action="javascript:void(0)" id="address_edit_form">
		<input type="hidden" name="deliveryAddressId"  value="${deliveryAddressVO.deliveryAddressId}"/>
		<input type="hidden" name="deliveryProvince" id="deliveryProvince"  value="${deliveryAddressVO.deliveryProvince}"/>
		<input type="hidden" name="deliveryCity" id="deliveryCity" value="${deliveryAddressVO.deliveryCity}"/>
		<input type="hidden" name="deliveryRegion" id="deliveryRegion" value="${deliveryAddressVO.deliveryRegion}"/>
		<div class="jd-index-header" id="address_header_div">
		   <div class="jd-index-header-title">
		                编辑收货地址
		   </div>
		</div>
		<div class="common-wrapper" id="address_content_div" >
		    <div class="address02">
		        <div class="fixed-top">
		            <div class="s-item bdb-1px">
		                <div class="sitem-l sitem-pad">
		                    <div class="sattr-add">收货人:</div>
		                    <div class="svalue"> 
		                    	<input type="text" maxlength="25" name="contactName"  size="23" value="${deliveryAddressVO.contactName}" class="ad-name">
		                    </div>
		                </div>
		            </div>
		            <div class="s-item bdb-1px">
		                <div class="sitem-l sitem-pad">
		                    <div class="sattr-add">手机号码:</div>
		                    <div id="mobileInputDiv" class="svalue">  
		                    	<input type="text" maxlength="11" name="contactPhone"  size="23" value="${deliveryAddressVO.contactPhone}" class="ad-mobile">
		                    </div>
		                </div>
		            </div>
		            <div class="s-item bdb-1px">
		                <div class="sitem-l sitem-pad" onclick="chooseAddress()">
		                    <div class="sattr-add">所在地区:</div>
		                    <div class="svalue"> 
		                    	<input type="text" id="sattr_add" size="23" value="${deliveryAddressVO.deliveryProvince}${deliveryAddressVO.deliveryCity}${deliveryAddressVO.deliveryRegion}" class="ad-name" readonly="readonly">
		                    </div>
		                </div>
		                <span class="s-point" onclick="chooseAddress()"></span>
		            </div>
		            <div class="s-item bdb-1px" >
		                <div class="sitem-l sitem-pad">
		                    <div class="sattr-add">详细地址:</div>
		                    <div  class="svalue">  
		                    	<input type="text" maxlength="200" size="23" name="deliveryAddress" value="${deliveryAddressVO.deliveryAddress}" class="ad-mobile" onfocus="javascript:addressFocus()" onBlur="javascript:addressBlur()">
		                    </div>
		                </div>
		            </div>
		         </div>
		    </div>
		</div>
		<div class="check-btn-auto" id="address_btn_div" >
		    <div class="check-btn-total" style="position:fixed;z-index: -1">
				<a href="javascript:saveAddress()" id="submitId" class="check-btn-red">保存并使用</a>
		    </div>
		</div>
	</form>
</div>


<div class="choose-address-page" id="choose_address_div" style="display: none;">
    <div class="head-fix">
        <header>
            <div class="jd-index-header">
                <div class="jd-index-header-title">地址选择</div>
            </div>
        </header>
        <ul class="head-address-ul" id="headAddressUl">
            <li id="province_head_li" onclick="headClick(1)" class="head-address-li">请选择</li>
            <li id="city_head_li" onclick="headClick(2)" class="head-address-li"></li>
            <li id="region_head_li" onclick="headClick(3)" class="head-address-li"></li>
        </ul>
    </div>
    <div class="address-container" id="addressContainer">
        <div class="address-content" id="addressContentDiv" style="-webkit-transform: translate(-828px, 0px) translateZ(0px); height: 647px;">
            <ul class="address-ul" id="privince_ul"></ul>
            <ul class="address-ul" id="city_ul"></ul>
            <ul class="address-ul" id="region_ul"></ul>
        </div>
    </div>
</div>
<script type="text/javascript" src="<%=path %>/js/address.js"></script>
<script type="text/javascript">
	function saveAddress(){
		var returnUrl="${returnUrl}";
		$.ajax({
			url : "<%=path%>/check/address/update",
			type : "post",
			dataType : "json",
			data : $("#address_edit_form").serialize(),
			success : function(data)
			{
				if(data.result){
					layer.msg("保存成功",{icon: 1});
					window.location.href=returnUrl;
				}else{
					layer.msg(data.message,{icon: 2});
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
			}
		});
	}
</script>
<jsp:include page="/views/html5/commons/footer.jsp"></jsp:include>
</body>
</html>
